﻿Public Class Snake
    Public cuerpo As Label() = {}
    Public Sub añadirCuerpo(ByVal pos As Point)
        Dim lbl As New Label
        lbl.AutoSize = False
        lbl.Text = ""
        lbl.BackColor = Color.DodgerBlue
        lbl.location = pos
        lbl.Visible = True
        lbl.Size = New Size(10, 10)
        lbl.Tag = New Point(lbl.location.X, lbl.location.Y)
        frmSnake.Controls.Add(lbl)
        Me.crearCuerpo(lbl)

    End Sub

    Public Sub crearCuerpo(ByVal lab As Label)
        ReDim Preserve cuerpo(cuerpo.Length)
        Me.cuerpo(cuerpo.Length - 1) = lab
    End Sub

    Public Sub movimiento()
        mySnake.cuerpo(0).Tag = mySnake.cuerpo(0).location
        mySnake.cuerpo(0).location = New Point(x, y)
        For i As Integer = 1 To mySnake.cuerpo.Length - 1
            mySnake.cuerpo(i).Tag = mySnake.cuerpo(i).location
            mySnake.cuerpo(i).location = mySnake.cuerpo(i - 1).Tag
        Next
    End Sub
    Public Sub IniciarSnake()
        x = 140
        y = 240
        Me.cuerpo = {}
        mySnake.añadirCuerpo(New Point(x, y))
        puntosTotales = 0
    End Sub

End Class
